﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using InternetModel;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace InternetDAL
{
   public class CargoManage
    {
        SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=ItemOne;Integrated Security=True");
        //public string connstr = ConfigurationManager.ConnectionStrings["connstring"].ConnectionString;
        /// <summary>
        /// 货物类型
        /// </summary>
        /// <returns></returns>
        public DataTable GetCargo()
        {
            string sql = "select * from Cargoclass ";
           // SqlConnection conn = new SqlConnection(connstr);//创建字符串对象
            SqlCommand command = new SqlCommand(sql, conn);
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            adapter.Fill(dt);
            return dt;

        }
        /// <summary>
        /// 货物存储
        /// </summary>
        /// <param name="news"></param>
        /// <returns></returns>
        public int AddCargo(Cargo news)
        {
            string sql = "insert Cargo values('" + news.Gname + "','" + news.Gclass + "','" + news.Gname + "','" + news.Gprice + "','" + news.Gtime + "','" + news.Gsourse + "','" + news.Gtelephone + "','" + news.Gaddres + "')";
           // SqlConnection conn = new SqlConnection(connstr);//创建字符串对象
            SqlCommand command = new SqlCommand(sql, conn);
            int result = command.ExecuteNonQuery();
            return result;

        }
    }
}
